
		function dateChange(name){
			var beginTimeObject = document.getElementById("startTime");
			var endTimeObject = document.getElementById("endTime");


			var beginTime;
			var endTime;
			var now = new Date();
			var month = now.getMonth();
			var year = now.getFullYear();
			var day = now.getDate();
			var wday = now.getDay();


			switch(name){
			case "tweek": //current week
			var day  = now.getDay();
			now.setDate(now.getDate() - (day -1));
			beginTime = formatDate(now);

			now.setDate(now.getDate() + 6);
			endTime = formatDate(now);
			
			break;
			case "tmonth":  //current month
			now.setDate(1);
			beginTime = formatDate(now);

			var days = getCountOfDays(now);
			now.setDate(days);
			endTime = formatDate(now);
			break;
			case "tquarter":   //current season
			var m = now.getMonth() + 1;
			var q = parseInt((m + 2 ) / 3 ); //nd season
			m = q * 3 - 2;  //the first season

			now.setMonth(m-1);
			now.setDate(1);
			beginTime = formatDate(now);

			now.setMonth(now.getMonth() + 3);
			now.setDate(0);
			endTime = formatDate(now);
			break;
			case "tyear":    //current year
			now.setMonth(0);
			now.setDate(1);
			beginTime = formatDate(now);

			now.setMonth(11);
			now.setDate(31);
			endTime = formatDate(now);        
			break;
			case "today":    //today
			beginTime = formatDate(now);
			endTime = beginTime;
			break;
			case "pweek":    //last week
			var day  = now.getDay();
			now.setDate(now.getDate() - (day -1) - 7 );
			beginTime = formatDate(now);

			now.setDate(now.getDate() + 6);
			endTime = formatDate(now);

			break;
			case "pmonth":    //last month
			now.setDate(1);
			now.setMonth(now.getMonth() -1 );
			beginTime = formatDate(now);

			var days = getCountOfDays(now);
			now.setDate(days);
			endTime = formatDate(now);
			break;
			case "pquarter":    //last season
			var m = now.getMonth() + 1;
			var q = parseInt((m + 2 ) / 3 ); //nd season
			m = q * 3 - 2;  //the frist month

			m = m-3 ; //last season
			now.setMonth(m-1);
			now.setDate(1);
			beginTime = formatDate(now);

			now.setMonth(now.getMonth() + 3);
			now.setDate(0);
			endTime = formatDate(now);        
			break;
			case "pyear":    //last year
			now.setFullYear(now.getFullYear() -1 );
			now.setMonth(0);
			now.setDate(1);
			beginTime = formatDate(now);

			now.setMonth(11);
			now.setDate(31);
			endTime = formatDate(now);            
			break;
			case "p2week":    //last two week
			var day  = now.getDay();
			now.setDate(now.getDate() - (day -1) - 7 *2);
			beginTime = formatDate(now);

			now.setDate(now.getDate() + 6 + 7);
			endTime = formatDate(now);            
			break;
			case "p2month":    //last two month
			now.setDate(1);
			now.setMonth(now.getMonth() -1*2 );
			beginTime = formatDate(now);

			now.setMonth(now.getMonth() + 2);
			now.setDate(0);
			endTime = formatDate(now);
			break;
			case "customize":    
			beginTime = "";
			endTime = "";
			break;
			}

			beginTimeObject.value = beginTime;
			endTimeObject.value = endTime;
			}

			function formatDate(_date){
				var year=_date.getYear();
				var month=_date.getMonth()+1;
				var date=_date.getDate();
				var ret=year+"/"+month+"/"+date;
				return ret;
			}

			//current day
			function currentDay(){
				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;

				var now = new Date();
				var month = now.getMonth();
				var year = now.getFullYear();
				var day = now.getDate();
				var wday = now.getDay();
				
				beginTime = formatDate(now);
				endTime = beginTime;
				
				beginTimeObject.value = beginTime;
				endTimeObject.value = "";
			}
			//current month
			function currentMonth(){
				
				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;

				var now = new Date();
				var month = now.getMonth();
				var year = now.getFullYear();
				var day = now.getDate();
				var wday = now.getDay();
				
				now.setDate(1);
				beginTime = formatDate(now);
				var days = getCountOfDays(now);
				now.setDate(days);

				endTime = formatDate(now);
				
				beginTimeObject.value = beginTime;
				endTimeObject.value = endTime;
				
			

			}
			//current week
			function currentWeek(){
				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;
				
				var now = new Date();
				var month = now.getMonth();
				var year = now.getFullYear();
				var day = now.getDate();
				var wday = now.getDay();
				
				now.setDate(now.getDate() - wday );
				beginTime = formatDate(now);

				now.setDate(now.getDate() + 6);
				endTime = formatDate(now);

				beginTimeObject.value = beginTime;
				endTimeObject.value = endTime;
			}
			function currentYear(){
				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;
				
				var now = new Date();
				var month = now.getMonth();
				var year = now.getFullYear();
				var day = now.getDate();
				var wday = now.getDay();
				
				now.setMonth(0);
				now.setDate(1);
				beginTime = formatDate(now);

				now.setMonth(11);
				now.setDate(31);
				endTime = formatDate(now);

				beginTimeObject.value = beginTime;
				endTimeObject.value = endTime; 
			}
			//last day
			function preDay(){

				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;
				
				var arr=beginTimeObject.value.split("/");
				var d=new Date(arr[0],arr[1]-1,arr[2]);
				var per=d.getTime()-24*60*60*1000;
				var ret=new Date(per);
				var str=ret.getYear()+"/"+(ret.getMonth()+1)+"/"+ret.getDate();

				beginTimeObject.value = str;
				endTimeObject.value = "";
			}
			//next day
			function nextDay(){
				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;

				var arr=beginTimeObject.value.split("/");
				var d=new Date(arr[0],arr[1]-1,arr[2]);
				var per=d.getTime()+24*60*60*1000;
				var ret=new Date(per);
				var str=ret.getYear()+"/"+(ret.getMonth()+1)+"/"+ret.getDate();

				beginTimeObject.value = str;
				endTimeObject.value = "";
			}
			//last week
			function preWeek(){
				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;
				
				var arr=beginTimeObject.value.split("/");
				var now=new Date(arr[0],arr[1]-1,arr[2]);
				var day  = now.getDay();
				
				now.setDate(now.getDate() -6 );
				beginTime = formatDate(now);

				now.setDate(now.getDate() +6);
				endTime = formatDate(now);

				
				beginTimeObject.value = beginTime;
				endTimeObject.value = endTime;

			}
			//next week
			function nextWeek(){
				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;
				
				var arr=beginTimeObject.value.split("/");
				var now=new Date(arr[0],arr[1]-1,arr[2]);
				var day  = now.getDay();
				now.setDate(now.getDate() + 6 );
				beginTime = formatDate(now);

				now.setDate(now.getDate() + 6);
				endTime = formatDate(now);

				beginTimeObject.value = beginTime;
				endTimeObject.value = endTime;

			}
			//last month
			function preMonth(){
				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;

				var arr=beginTimeObject.value.split("/");
				var now=new Date(arr[0],arr[1]-1,arr[2]);

				now.setDate(1);
				now.setMonth(now.getMonth() -1 );
				beginTime = formatDate(now);

				var days = getCountOfDays(now);
				now.setDate(days);
				endTime = formatDate(now);

				beginTimeObject.value = beginTime;
				endTimeObject.value = endTime;



			}
			//next month
			function nextMonth(){
				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;

				var arr=beginTimeObject.value.split("/");
				var now=new Date(arr[0],arr[1]-1,arr[2]);

				now.setDate(1);
				now.setMonth(now.getMonth() +1 );
				beginTime = formatDate(now);

				var days = getCountOfDays(now);
				now.setDate(days);
				endTime = formatDate(now);

				beginTimeObject.value = beginTime;
				endTimeObject.value = endTime;

			}
			function preYear(){
				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;

				var arr=beginTimeObject.value.split("/");
				var now=new Date(arr[0],arr[1]-1,arr[2]);
	
				now.setDate(1);
				now.setMonth(0)
				now.setYear(now.getYear() -1 );
				beginTime = formatDate(now);
	
				now.setDate(31);
				now.setMonth(11)
				endTime = formatDate(now);

				beginTimeObject.value = beginTime;
				endTimeObject.value = endTime;
			}
			function nextYear(){
				var beginTimeObject = document.getElementById("startTime");
				var endTimeObject = document.getElementById("endTime");
				var beginTime;
				var endTime;

				var arr=beginTimeObject.value.split("/");
				var now=new Date(arr[0],arr[1]-1,arr[2]);
	
				now.setDate(1);
				now.setMonth(0)
				now.setYear(now.getYear() +1 );
				beginTime = formatDate(now);
	
				now.setDate(31);
				now.setMonth(11)
				endTime = formatDate(now);

				beginTimeObject.value = beginTime;
				endTimeObject.value = endTime;
			}

			//to choose
		function select(_form){
			var val=document.getElementById("arrType").value;
			document.getElementById("selectByDate").checked=true;
			if(val==""||val=="all"){
				document.getElementById("startTime").value="";
				document.getElementById("endTime").value="";
				document.getElementById("selectByDate").checked=false;
			}else if(val=="day"){
				currentDay();
				
			}else if(val=="week"){
				currentWeek();

			}else if(val=="month"){
				currentMonth();
				
			}else if(val=="year"){
				currentYear();
			}
			//here submit the form
			document.getElementById(_form).submit();
		}
		//next
		function next(_form){
			var val=document.getElementById("arrType").value;
			var startTime=document.getElementById("startTime");
			var endTime=document.getElementById("endTime");
			var temp=endTime.value;
			var next="";
			if(val=="day"){
				next=nextDay(endTime.value);

			}else if(val=="week"){
				next=nextWeek();

			}else if(val=="month"){
				next=nextMonth();

			}else if(val=="year"){
				next=nextYear();
			}
			document.getElementById(_form).submit();
		}
		//previous
		function pre(_form){
			var val=document.getElementById("arrType").value;
			var startTime=document.getElementById("startTime");
			var endTime=document.getElementById("endTime");
			var temp=startTime.value;
			var pre="";
			if(val=="day"){
				pre=preDay();

			}else if(val=="week"){
				pre=preWeek();

			}else if(val=="month"){
				pre=preMonth();
			}else if(val=="year"){
				pre=preYear();
			}
			document.getElementById(_form).submit();
		}
		function getCountOfDays(_date){
				var m=_date.getMonth()+1;
				var y=_date.getYear();
				var ret=31;
				if(m==1||m==3||m==5||m==7||m==8||m==10||m==12){
					ret=31;
				}else if(m==4||m==6||m==9||m==11){
					ret=30;
				}else if(y%4==0&&y%100==0&&y%400==0){
					ret=29;
				}else{
					ret=28;
				}
			return ret;
		}
		function getCountBetweenDate(_date1,_date2){
			var arr=_date1.split("/");
			var d1=new Date(arr[0],arr[1]-1,arr[2]);
			arr=_date2.split("/");
			var d2=new Date(arr[0],arr[1]-1,arr[2]);
			
			var be=d2.getTime()-d1.getTime();
			
			if(be<0)
				return -1;
			else if(be==0)
				return 1;
			
			var day=be/1000/24/60/60+1;
			return day;
			
		}
		